﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace PJ.Data.SalePurchase
{
    [Serializable]
    [DataContract]
    public abstract class BaseShoppingCartItemData : BaseOrderedFragmentData, IShoppingCartItemData
    {
        private string m_InventoryItemID;
        private string m_UnitID;
        private double m_Quantity;

        [DataMember]
        public string UnitId
        {
            get { return m_UnitID; }
            set { m_UnitID = value; }
        }

        [DataMember]
        public double Quantity
        {
            get { return m_Quantity; }
            set { m_Quantity = value; }
        }

        [DataMember]
        public string InventoryItemId
        {
            get { return m_InventoryItemID; }
            set { m_InventoryItemID = value; }
        }

        protected BaseShoppingCartItemData()
        {
        }
        protected BaseShoppingCartItemData(IShoppingCartItemData data)
            : base(data)
        {
        }
        public override IObjectData Copy(IObjectData data)
        {
            base.Copy(data);
            IShoppingCartItemData item = (IShoppingCartItemData)data;
            this.InventoryItemId = item.InventoryItemId;
            this.UnitId = item.UnitId;
            this.Quantity = item.Quantity;
            return this;
        }
        public override bool IsEqual(IObjectData data)
        {
            if (base.IsEqual(data))
            {
                IShoppingCartItemData item = (IShoppingCartItemData)data;
                if (item.InventoryItemId == this.InventoryItemId)
                    if (item.Quantity == this.Quantity)
                        if (item.UnitId == this.UnitId)
                            return true;
            }
            return false;
        }

    }
}
